Eliminiate redundant route_head data member (#764)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Wed, 17 Nov 2021 15:52:08 +0000 (08:52 -0700)
committerGitHub <noreply@github.com>
Wed, 17 Nov 2021 15:52:08 +0000 (08:52 -0700)
eliminate redundant route_head data member rte_waypt_ct, replacing it with a member function rte_waypt_ct() that gets the count from the waypoint_list container.

29 files changed:
bcr.cc
defs.h
garmin_txt.cc
gdb.cc
ggv_ovl.cc
gtm.cc
humminbird.cc
igc.cc
ignrando.cc
kml.cc
lowranceusr.cc
magproto.cc
mapsend.cc
mmo.cc
navilink.cc
osm.cc
ozi.cc
position.cc
raymarine.cc
route.cc
saroute.cc
shape.cc
skyforce.cc
smplrout.cc
stmsdf.cc
tpo.cc
trackfilter.cc
validate.cc
xol.cc

diff --git a/bcr.cc b/bcr.cc
index 1954ced342e1e7588a3c0c51b313e1b2e1009d6b..1d744c8e7e42458c66a6c85881b88725331dc3bd 100644 (file)
--- a/bcr.cc
+++ b/bcr.cc
@@ -297,7 +297,7 @@ bcr_data_read()
   }
 
   /* remove empty route */
-  if (route->rte_waypt_ct == 0) {
+  if (route->rte_waypt_ct() == 0) {
     route_del_head(route);
   } else {
     bcr_create_waypts_from_route(route);
diff --git a/defs.h b/defs.h
index 68c14159decf5e530a3125efc66109c9b0ad1ec4..a1dfa506a098e7059908bb3a4a1cff53dfbdd324 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -702,7 +702,6 @@ public:
   QString rte_desc;
   UrlList rte_urls;
   int rte_num;
-  int rte_waypt_ct;            /* # waypoints in waypoint list */
   FormatSpecificDataList fs;
   gb_color line_color;         /* Optional line color for rendering */
   int line_width;         /* in pixels (sigh).  < 0 is unknown. */
@@ -716,6 +715,8 @@ public:
   route_head(const route_head& other) = delete;
   route_head& operator=(const route_head& rhs) = delete;
   ~route_head();
+
+  int rte_waypt_ct() const {return waypoint_list.count();}             /* # waypoints in waypoint list */
 };
 
 using route_hdr = void (*)(const route_head*);
index 485bf3c9ea7bf0842f13cf8c2d893cfab8c5d32b..f4998411220414ca2a413ff97b84127284ff1577 100644 (file)
@@ -621,7 +621,7 @@ route_disp_hdr_cb(const route_head* rte)
   cur_info = &route_info[route_idx];
   cur_info->prev_wpt = nullptr;
   cur_info->total = 0;
-  if (rte->rte_waypt_ct <= 0) {
+  if (rte->rte_waypt_ct() <= 0) {
     return;
   }
 
@@ -675,7 +675,7 @@ track_disp_hdr_cb(const route_head* track)
   cur_info = &route_info[route_idx];
   cur_info->prev_wpt = nullptr;
   cur_info->total = 0;
-  if (track->rte_waypt_ct <= 0) {
+  if (track->rte_waypt_ct() <= 0) {
     return;
   }
 
diff --git a/gdb.cc b/gdb.cc
index dd901bdf9a172fa7408c623c3c555bdf5e1a83cc..60750580244a78b4ca4c2bb65022bba254942d69 100644 (file)
--- a/gdb.cc
+++ b/gdb.cc
@@ -112,7 +112,7 @@ static int trk_ct;  /* informational: total number of tracks in/out */
 
 /*******************************************************************************/
 
-#define ELEMENTS(a) a->rte_waypt_ct
+#define ELEMENTS(a) a->rte_waypt_ct()
 #define NOT_EMPTY(a) (a && *a)
 
 static void
index 21f03e553ae22a29d8cfd827022248c9e3774b43..c862dce2bb02674548206c82cf8582c18d8bc571 100644 (file)
@@ -266,7 +266,7 @@ waypt_disp_cb(const Waypoint* wpt)
 static void
 track_disp_cb(const route_head* trk)
 {
-  int waypt_ct = trk->rte_waypt_ct;
+  int waypt_ct = trk->rte_waypt_ct();
 
   if (waypt_ct <= 0) {
     return;
@@ -294,7 +294,7 @@ track_disp_cb(const route_head* trk)
 static void
 route_disp_cb(const route_head* rte)
 {
-  int waypt_ct = rte->rte_waypt_ct;
+  int waypt_ct = rte->rte_waypt_ct();
 
   if (waypt_ct <= 0) {
     return;
diff --git a/gtm.cc b/gtm.cc
index 82c23766c0b470d5081468eb217680031940bdb5..d0581d42f5c45b828b1d6be7554047b40601ace7 100644 (file)
--- a/gtm.cc
+++ b/gtm.cc
@@ -416,7 +416,7 @@ gtm_rd_deinit()
 
 static void count_track_styles(const route_head* rte)
 {
-  if (rte->rte_waypt_ct > 0) {
+  if (rte->rte_waypt_ct() > 0) {
     ts_count++;
   }
 }
@@ -670,7 +670,7 @@ static void write_trk_waypt(const Waypoint* wpt)
 
 static void write_trk_style(const route_head* trk)
 {
-  if (trk->rte_waypt_ct > 0) {
+  if (trk->rte_waypt_ct() > 0) {
     fwrite_string(file_out, trk->rte_name);
     fwrite_byte(file_out, 1);
     fwrite_long(file_out, 0);
index 4033937082ace0968f9df4eab6759ec84857f347..40765ec489f390877af6c75e108e321a952170f6 100644 (file)
@@ -729,7 +729,7 @@ humminbird_track_head(const route_head* trk)
 
   trk_head = nullptr;
   last_time = 0;
-  if (trk->rte_waypt_ct > 0) {
+  if (trk->rte_waypt_ct() > 0) {
     trk_head = (humminbird_trk_header_t*) xcalloc(1, sizeof(humminbird_trk_header_t));
     trk_points = (humminbird_trk_point_t*) xcalloc(max_points, sizeof(humminbird_trk_point_t));
 
@@ -852,7 +852,7 @@ static void
 humminbird_rte_head(const route_head* rte)
 {
   humrte = nullptr;
-  if (rte->rte_waypt_ct > 0) {
+  if (rte->rte_waypt_ct() > 0) {
     humrte = (humminbird_rte_t*) xcalloc(1, sizeof(*humrte));
   }
 }
diff --git a/igc.cc b/igc.cc
index d728595d3309ea953b3183a0754dcbcf8dee8ed5..faa3065baac088c4ce990c72ccc25cf3d951d1d7 100644 (file)
--- a/igc.cc
+++ b/igc.cc
@@ -499,12 +499,12 @@ static void detect_other_track(const route_head* rh)
     max_waypt_ct = 0;
   }
   // Find other track with the most waypoints
-  if (rh->rte_waypt_ct > max_waypt_ct &&
+  if (rh->rte_waypt_ct() > max_waypt_ct &&
       (rh->rte_name.isEmpty() ||
        (!rh->rte_name.startsWith(PRESTRKNAME) &&
        !rh->rte_name.startsWith(GNSSTRKNAME)))) {
     head = rh;
-    max_waypt_ct = rh->rte_waypt_ct;
+    max_waypt_ct = rh->rte_waypt_ct();
   }
 }
 
@@ -651,7 +651,7 @@ static void wr_task_hdr(const route_head* rte)
   unsigned char have_takeoff = 0;
   char flight_date[7] = "000000";
   char task_desc[MAXRECLEN] = "";
-  int num_tps = rte->rte_waypt_ct - 2;
+  int num_tps = rte->rte_waypt_ct() - 2;
   struct tm* tm;
   time_t rte_time;
   static unsigned int task_num = 1;
index fdda2e7bd39637216cdaf452b319be14f1db0699..5fe43a76eeab634e2a0e2868dc948891b6a431e8 100644 (file)
@@ -219,7 +219,7 @@ ignr_write_track_hdr(const route_head* track_hdr)
   }
 
   gbfprintf(fout, "\t<INFORMATIONS>\n");
-  gbfprintf(fout, "\t\t<NB_ETAPES>%d</NB_ETAPES>\n", track_hdr->rte_waypt_ct);
+  gbfprintf(fout, "\t\t<NB_ETAPES>%d</NB_ETAPES>\n", track_hdr->rte_waypt_ct());
   if (!track_hdr->rte_desc.isEmpty()) {
     gbfprintf(fout, "\t\t<DESCRIPTION>%s</DESCRIPTION>\n", STRFROMUNICODE(track_hdr->rte_desc));
   }
diff --git a/kml.cc b/kml.cc
index a548e5b858a58d68cd272bc8c23550c0cec1f7e9..695b30d65a802001110d3d3a641d2fa5108a9803 100644 (file)
--- a/kml.cc
+++ b/kml.cc
@@ -251,12 +251,12 @@ void KmlFormat::trk_coord(xg_string args, const QXmlStreamAttributes* /*attrs*/)
   if (wpt_timespan_begin.isValid() && wpt_timespan_end.isValid()) {
 
     // If there are some Waypoints, then distribute the TimeSpan to all Waypoints
-    if (trk_head->rte_waypt_ct > 0) {
+    if (trk_head->rte_waypt_ct() > 0) {
       qint64 timespan_ms = wpt_timespan_begin.msecsTo(wpt_timespan_end);
-      if (trk_head->rte_waypt_ct < 2) {
+      if (trk_head->rte_waypt_ct() < 2) {
         fatal(MYNAME ": attempt to interpolate TimeSpan with too few points.");
       }
-      qint64 ms_per_waypoint = timespan_ms / (trk_head->rte_waypt_ct - 1);
+      qint64 ms_per_waypoint = timespan_ms / (trk_head->rte_waypt_ct() - 1);
       foreach (Waypoint* trackpoint, trk_head->waypoint_list) {
         trackpoint->SetCreationTime(wpt_timespan_begin);
         wpt_timespan_begin = wpt_timespan_begin.addMSecs(ms_per_waypoint);
@@ -315,7 +315,7 @@ void KmlFormat::gx_trk_e(xg_string /*args*/, const QXmlStreamAttributes* /*attrs
     }
   }
 
-  if (!gx_trk_head->rte_waypt_ct) {
+  if (!gx_trk_head->rte_waypt_ct()) {
     track_del_head(gx_trk_head);
   }
   delete gx_trk_times;
@@ -662,7 +662,7 @@ void KmlFormat::kml_output_header(const route_head* header, const computed_trkda
   writer->writeOptionalTextElement(QStringLiteral("name"), header->rte_name);
   kml_output_trkdescription(header, td);
 
-  if (export_points && header->rte_waypt_ct > 0) {
+  if (export_points && header->rte_waypt_ct() > 0) {
     // Put the points in a subfolder
     writer->writeStartElement(QStringLiteral("Folder"));
     writer->writeTextElement(QStringLiteral("name"), QStringLiteral("Points"));
@@ -880,12 +880,12 @@ void KmlFormat::kml_output_point(const Waypoint* waypointp, kml_point_type pt_ty
 void KmlFormat::kml_output_tailer(const route_head* header)
 {
 
-  if (export_points && header->rte_waypt_ct > 0) {
+  if (export_points && header->rte_waypt_ct() > 0) {
     writer->writeEndElement(); // Close Folder tag
   }
 
   // Add a linestring for this track?
-  if (export_lines && header->rte_waypt_ct > 0) {
+  if (export_lines && header->rte_waypt_ct() > 0) {
     int needs_multigeometry = 0;
 
     foreach (const Waypoint* tpt, header->waypoint_list) {
@@ -1459,7 +1459,7 @@ void KmlFormat::kml_waypt_pr(const Waypoint* waypointp) const
 void KmlFormat::kml_track_hdr(const route_head* header) const
 {
   computed_trkdata td = track_recompute(header);
-  if (header->rte_waypt_ct > 0 && (export_lines || export_points)) {
+  if (header->rte_waypt_ct() > 0 && (export_lines || export_points)) {
     kml_output_header(header, &td);
   }
 }
@@ -1471,7 +1471,7 @@ void KmlFormat::kml_track_disp(const Waypoint* waypointp) const
 
 void KmlFormat::kml_track_tlr(const route_head* header)
 {
-  if (header->rte_waypt_ct > 0 && (export_lines || export_points)) {
+  if (header->rte_waypt_ct() > 0 && (export_lines || export_points)) {
     kml_output_tailer(header);
   }
 }
@@ -2002,7 +2002,7 @@ void KmlFormat::wr_position(Waypoint* wpt)
    * head here.
    */
   while (max_position_points &&
-         (posn_trk_head->rte_waypt_ct >= max_position_points)) {
+         (posn_trk_head->rte_waypt_ct() >= max_position_points)) {
     Waypoint* tonuke = posn_trk_head->waypoint_list.front();
     track_del_wpt(posn_trk_head, tonuke);
   }
index b72ab47a48b626222a28ec619a143cefa689f562..6e51a0f42e05697cabf2574e7d1f0e63a10e678c 100644 (file)
@@ -1560,7 +1560,7 @@ LowranceusrFormat::lowranceusr_trail_hdr(const route_head* trk)
   gbfputint32(text_len, file_out);
   gbfwrite(CSTR(name), 1, text_len, file_out);
 
-  auto num_trail_points = (short) trk->rte_waypt_ct;
+  auto num_trail_points = (short) trk->rte_waypt_ct();
   short max_trail_size = MAX_TRAIL_POINTS;
   if (num_trail_points > max_trail_size) {
     num_trail_points = max_trail_size;
@@ -1602,7 +1602,7 @@ LowranceusrFormat::lowranceusr_route_hdr(const route_head* rte)
   gbfputs(name, file_out);
 
   /* num legs */
-  auto num_legs = (short) rte->rte_waypt_ct;
+  auto num_legs = (short) rte->rte_waypt_ct();
   gbfputint16(num_legs, file_out);
   char route_reversed=0;
   gbfwrite(&route_reversed, 1, 1, file_out);
@@ -1617,7 +1617,7 @@ LowranceusrFormat::lowranceusr4_route_hdr(const route_head* rte)
 {
   if (global_opts.debug_level >= 1) {
     printf(MYNAME " writing route #%d (%s) with %d waypts\n",
-           route_uid, qPrintable(rte->rte_name), rte->rte_waypt_ct);
+           route_uid, qPrintable(rte->rte_name), rte->rte_waypt_ct());
   }
 
   const auto* fs = reinterpret_cast<lowranceusr4_fsdata*>(rte->fs.FsChainFind(kFsLowranceusr4));
@@ -1642,7 +1642,7 @@ LowranceusrFormat::lowranceusr4_route_hdr(const route_head* rte)
   lowranceusr4_writestr(rte->rte_name, file_out, 2);
 
   /* Num Legs */
-  gbfputint32(rte->rte_waypt_ct, file_out);
+  gbfputint32(rte->rte_waypt_ct(), file_out);
 }
 
 void
@@ -1720,7 +1720,7 @@ LowranceusrFormat::lowranceusr_merge_trail_hdr(const route_head* trk)
     }
   }
 
-  trail_point_count += (short) trk->rte_waypt_ct;
+  trail_point_count += (short) trk->rte_waypt_ct();
 }
 
 void
@@ -1756,7 +1756,7 @@ LowranceusrFormat::lowranceusr4_trail_hdr(const route_head* trail)
 {
   if (global_opts.debug_level >= 1) {
     printf(MYNAME " writing trail %d (%s) with %d trailpoints\n",
-           trail_uid, qPrintable(trail->rte_name), trail->rte_waypt_ct);
+           trail_uid, qPrintable(trail->rte_name), trail->rte_waypt_ct());
   }
 
   /* UID unit number */
@@ -1803,7 +1803,7 @@ LowranceusrFormat::lowranceusr4_trail_hdr(const route_head* trail)
 //  }
 
   /* Trackpoint count */
-  gbfputint32(trail->rte_waypt_ct, file_out);
+  gbfputint32(trail->rte_waypt_ct(), file_out);
 }
 
 void
index ed707aec18c78bd239fcef7f43bf92d03cd3e8b9..ca9fb5adb51b9364b046d18d86bd9fadb280b9fd 100644 (file)
@@ -1471,7 +1471,7 @@ mag_route_trl(const route_head* rte)
   QString icon_token;
 
   /* count waypoints for this route */
-  int i = rte->rte_waypt_ct;
+  int i = rte->rte_waypt_ct();
 
   /* number of output PMGNRTE messages at 2 points per line */
   int numlines = (i / 2) + (i % 2);
index b920938f32f7c5e99ed6e0c4897846645400a895..61c761dce190efa0028a7ab74d966a30561bf6d7 100644 (file)
@@ -359,7 +359,7 @@ mapsend_route_hdr(const route_head* rte)
   gbfputint32(rte->rte_num, mapsend_file_out);
 
   /* # of waypoints to follow... */
-  gbfputint32(rte->rte_waypt_ct, mapsend_file_out);
+  gbfputint32(rte->rte_waypt_ct(), mapsend_file_out);
 }
 
 static void
diff --git a/mmo.cc b/mmo.cc
index cb3641f193e4b9d92ce7f7051cb8b6a4672a0451..ddf41b046752dab10550cfcb3062369ac1f9d345 100644 (file)
--- a/mmo.cc
+++ b/mmo.cc
@@ -350,7 +350,7 @@ mmo_end_of_route(mmo_data_t* data)
     DBG((sobj, "for \"%s\" \n", data->name));
   }
 
-  if (rte->rte_waypt_ct == 0) {        /* don't keep empty routes */
+  if (rte->rte_waypt_ct() == 0) {      /* don't keep empty routes */
     route_del_head(rte);
     data->data = nullptr;
   }
@@ -721,7 +721,7 @@ mmo_read_CObjTrack(mmo_data_t* data)
     }
   }
 
-  if (trk->rte_waypt_ct == 0) {
+  if (trk->rte_waypt_ct() == 0) {
     track_del_head(trk);
     data->data = nullptr;
   }
@@ -1127,7 +1127,7 @@ mmo_enum_waypt_cb(const Waypoint*)
 static void
 mmo_enum_route_cb(const route_head* rte)
 {
-  if (rte->rte_waypt_ct > 0) {
+  if (rte->rte_waypt_ct() > 0) {
     mmo_obj_ct++;
   }
 }
@@ -1293,7 +1293,7 @@ mmo_write_rte_head_cb(const route_head* rte)
 {
   time_t time = 0x7FFFFFFF;
 
-  if (rte->rte_waypt_ct <= 0) {
+  if (rte->rte_waypt_ct() <= 0) {
     return;
   }
 
@@ -1313,18 +1313,18 @@ mmo_write_rte_head_cb(const route_head* rte)
   mmo_register_object(objid, rte, rtedata);
   mmo_write_category("CCategory", "Route");
   gbfputc(0, fout); /* unknown */
-  gbfputuint16(rte->rte_waypt_ct, fout);
+  gbfputuint16(rte->rte_waypt_ct(), fout);
 }
 
 
 static void
 mmo_write_rte_tail_cb(const route_head* rte)
 {
-  if (rte->rte_waypt_ct <= 0) {
+  if (rte->rte_waypt_ct() <= 0) {
     return;
   }
 
-  DBG(("write", "route with %d point(s).\n", rte->rte_waypt_ct));
+  DBG(("write", "route with %d point(s).\n", rte->rte_waypt_ct()));
 
   if (mmo_version >= 0x12) {
     if (rte->line_color.bbggrr < 0) {
@@ -1350,14 +1350,14 @@ mmo_write_rte_tail_cb(const route_head* rte)
 static void
 mmo_write_trk_head_cb(const route_head* trk)
 {
-  if (trk->rte_waypt_ct <= 0) {
+  if (trk->rte_waypt_ct() <= 0) {
     return;
   }
   int objid = mmo_write_obj_head("CObjTrack",
                                  trk->rte_name.isEmpty() ? "Track" : CSTR(trk->rte_name), gpsbabel_time, obj_type_trk);
 
   mmo_write_category("CCategory", "Track");
-  gbfputuint16(trk->rte_waypt_ct, fout);
+  gbfputuint16(trk->rte_waypt_ct(), fout);
 
   mmo_register_object(objid, trk, trkdata);
 }
@@ -1366,7 +1366,7 @@ mmo_write_trk_head_cb(const route_head* trk)
 static void
 mmo_write_trk_tail_cb(const route_head* trk)
 {
-  if (trk->rte_waypt_ct <= 0) {
+  if (trk->rte_waypt_ct() <= 0) {
     return;
   }
 
index 2c15b620ac4af97d6df5e0cda09a3b633325de8e..6f92e27124e579fd2a6ac0ee04d8d2309d7cc9d5 100644 (file)
@@ -684,7 +684,7 @@ serial_read_routes(Waypoint** waypts)
 static void
 serial_write_route_start(const route_head* route)
 {
-  route_ids = (unsigned int*) xmalloc(route->rte_waypt_ct * sizeof(unsigned));
+  route_ids = (unsigned int*) xmalloc(route->rte_waypt_ct() * sizeof(unsigned));
   route_id_ptr = 0;
 }
 
diff --git a/osm.cc b/osm.cc
index 30b85a2b2dfd48308c4228e417bd2747f474a87a..a34c5b9b28be250c96aea2750e7c3c4557a387cb 100644 (file)
--- a/osm.cc
+++ b/osm.cc
@@ -803,7 +803,7 @@ OsmFormat::osm_waypt_disp(const Waypoint* waypoint)
 void
 OsmFormat::osm_rte_disp_head(const route_head* route)
 {
-  skip_rte = route->rte_waypt_ct <= 0;
+  skip_rte = route->rte_waypt_ct() <= 0;
 
   if (skip_rte) {
     return;
diff --git a/ozi.cc b/ozi.cc
index 4e218d3d19f1d90119b4fc913ff9ffdebafeb3f3..228122f80b20f11beca9e35094ead7b1f6802fda 100644 (file)
--- a/ozi.cc
+++ b/ozi.cc
@@ -609,7 +609,7 @@ ozi_parse_track(int field, const QString& str, Waypoint* wpt_tmp, char* trk_name
     break;
   case 2:
     /* new track flag */
-    if ((str.toInt() == 1) && (trk_head->rte_waypt_ct > 0)) {
+    if ((str.toInt() == 1) && (trk_head->rte_waypt_ct() > 0)) {
       trk_head = new route_head;
       track_add_head(trk_head);
       if (trk_name) {
index bb372f956a534cfd210dc68c169a5648ba83b423..23ccd3381e201f561ae6fdd66ee48ea27fb53d8f 100644 (file)
@@ -124,7 +124,7 @@ void PositionFilter::position_runqueue(WaypointList* waypt_list, int qtype)
 
 void PositionFilter::position_process_any_route(const route_head* rh, int type)
 {
-  if (rh->rte_waypt_ct != 0) {
+  if (rh->rte_waypt_ct() != 0) {
     cur_rte = const_cast<route_head*>(rh);
     position_runqueue(&cur_rte->waypoint_list, type);
     cur_rte = nullptr;
index 75fc6ec7a7cffb52f617de9964fb6e45962c240e..aaa1988dd424d10dfbf1853841fc5c548989a22b 100644 (file)
@@ -415,7 +415,7 @@ write_route_wpt_cb(const Waypoint* wpt)
 static void
 enum_route_hdr_cb(const route_head* rte)
 {
-  is_fatal(rte->rte_waypt_ct > 50,
+  is_fatal(rte->rte_waypt_ct() > 50,
            MYNAME ": Routes with more than 50 points are not supported by Raymarine!");
 }
 
index ee03684e7ebe0af5a59d26e4d94dfa9a11bb9a52..115a119fe9c551110a3fd6c081bd5439eb1c2bd2 100644 (file)
--- a/route.cc
+++ b/route.cc
@@ -358,7 +358,6 @@ computed_trkdata track_recompute(const route_head* trk)
 
 route_head::route_head() :
   rte_num(0),
-  rte_waypt_ct(0),
   // line_color(),
   line_width(-1),
   session(curr_session())
@@ -389,7 +388,7 @@ RouteList::add_head(route_head* rte)
 void
 RouteList::del_head(route_head* rte)
 {
-  waypt_ct -= rte->rte_waypt_ct;
+  waypt_ct -= rte->rte_waypt_ct();
   const int idx = this->indexOf(rte);
   assert(idx >= 0);
   removeAt(idx);
@@ -411,7 +410,6 @@ RouteList::insert_head(route_head* rte, route_head* predecessor)
 void
 RouteList::add_wpt(route_head* rte, Waypoint* wpt, bool synth, const QString& namepart, int number_digits)
 {
-  rte->rte_waypt_ct++; /* waypoints in this route */
   ++waypt_ct;
   rte->waypoint_list.add_rte_waypt(waypt_ct, wpt, synth, namepart, number_digits);
   if ((this == global_route_list) || (this == global_track_list)) {
@@ -423,7 +421,6 @@ void
 RouteList::del_wpt(route_head* rte, Waypoint* wpt)
 {
   rte->waypoint_list.del_rte_waypt(wpt);
-  rte->rte_waypt_ct--;
   --waypt_ct;
 }
 
@@ -467,7 +464,6 @@ RouteList::copy(RouteList** dst) const
     rte_new->rte_desc = rte_old->rte_desc;
     rte_new->rte_urls = rte_old->rte_urls;
     rte_new->rte_num = rte_old->rte_num;
-    // rte_waypt_ct created below with add_wpt.
     rte_new->fs = rte_old->fs.FsChainCopy();
     rte_new->line_color = rte_old->line_color;
     rte_new->line_width = rte_old->line_width;
index eac684804e13f93e3ce708051539a25160b14ad6..a02044f4beb2be925e2fdea8ec7cecf69ddc75c7 100644 (file)
@@ -285,7 +285,7 @@ my_read()
       record = ReadRecord(infile, recsize);
       stringlen = le_read16((uint16_t*)record);
       if (split && stringlen) {
-        if (track_head->rte_waypt_ct) {
+        if (track_head->rte_waypt_ct()) {
           old_track_head = track_head;
           track_head = new route_head;
           if (timesynth) {
index 6bb81a4996c38c4442b010c2f6f2b48f9f3bedda..874ddb0aab36ab3e4b76a4e3074d9a6ba6e86be2 100644 (file)
--- a/shape.cc
+++ b/shape.cc
@@ -422,7 +422,7 @@ ShapeFormat::write_wpt(const Waypoint* wpt) const
 void
 ShapeFormat::poly_init(const route_head* rte)
 {
-  const int ct = rte->rte_waypt_ct;
+  const int ct = rte->rte_waypt_ct();
   poly_count = 0;
   polybufx = new double[ct];
   polybufy = new double[ct];
@@ -446,7 +446,7 @@ ShapeFormat::poly_deinit(const route_head* rte)
   // to SHPT_ARC.
   // We could potentially write SHPT_ARCZ, but we would have
   // to address what to do when we don't have altitude data.
-  assert(rte->rte_waypt_ct == poly_count);
+  assert(rte->rte_waypt_ct() == poly_count);
   SHPObject* shpobject = SHPCreateSimpleObject(SHPT_ARC, poly_count,
                          polybufx, polybufy, polybufz);
   int iShape = SHPWriteObject(ohandle, -1,  shpobject);
index 51bef2b5b8401e8cd3b045d486fe5640c751d8b6..b5152f15e90596caefad0499e7750723b679f99f 100644 (file)
@@ -123,7 +123,7 @@ static void
 skyforce_head_disp_cb(const route_head* head)
 {
   prev_wpt = nullptr;
-  if (head->rte_waypt_ct <= 0) {
+  if (head->rte_waypt_ct() <= 0) {
     return;
   }
 
index eb67a2fa5f844c69822c1b53681515f0d31f6959..56921379768a41740e3256f8193e2ef312b729bb 100644 (file)
@@ -195,16 +195,16 @@ void SimplifyRouteFilter::routesimple_head(const route_head* rte)
   totalerror = 0;
 
   /* short-circuit if we already have fewer than the max points */
-  if (countopt && count >= rte->rte_waypt_ct) {
+  if (countopt && count >= rte->rte_waypt_ct()) {
     return;
   }
 
   /* short-circuit if the route is impossible to simplify, too. */
-  if (2 >= rte->rte_waypt_ct) {
+  if (2 >= rte->rte_waypt_ct()) {
     return;
   }
 
-  xte_recs = new struct xte[rte->rte_waypt_ct];
+  xte_recs = new struct xte[rte->rte_waypt_ct()];
   cur_rte = rte;
 
 }
index a7e3e7c1760a82a3a389367af492bd1c8a22378a..0787696cd1078e2b51ef1082279aa19477b3e6ff 100644 (file)
--- a/stmsdf.cc
+++ b/stmsdf.cc
@@ -605,7 +605,7 @@ track_disp_wpt_cb(const Waypoint* wpt)
   calculate(wpt, &dist, &speed, &course, nullptr, nullptr);
   trkpt_dist = trkpt_dist + dist;
 
-  if (track_points == trk_out->rte_waypt_ct) { /* I'm the last in that list */
+  if (track_points == trk_out->rte_waypt_ct()) {       /* I'm the last in that list */
     if (all_track_points != saved_track_points) {      /* but not the overall latest */
       flag = 1;
     }
diff --git a/tpo.cc b/tpo.cc
index c47741156001eb5d7a331905be699396f1343ab1..17729af6322cd1c8a8aa563e7e6e03ae951c3459 100644 (file)
--- a/tpo.cc
+++ b/tpo.cc
@@ -1943,7 +1943,7 @@ tpo_track_hdr(const route_head* rte)
   gbfwrite(bounding_box, 1, sizeof(bounding_box), tpo_file_out);
 
   /* number of route points */
-  gbfputint16(rte->rte_waypt_ct, tpo_file_out);
+  gbfputint16(rte->rte_waypt_ct(), tpo_file_out);
 
   /* initialize the track length computation */
   track_length = 0;
index 079bf36e7c71dfcebf458ac23fb6108b0f953301..39b82c27632fe16758c988ae5e03e32a847bda7a 100644 (file)
@@ -179,7 +179,7 @@ QDateTime TrackFilter::trackfilter_get_last_time(const route_head* track)
 
 void TrackFilter::trackfilter_fill_track_list_cb(const route_head* track)      /* callback for track_disp_all */
 {
-  if (track->rte_waypt_ct == 0) {
+  if (track->rte_waypt_ct() == 0) {
     track_del_head(const_cast<route_head*>(track));
     return;
   }
@@ -223,7 +223,7 @@ void TrackFilter::trackfilter_fill_track_list_cb(const route_head* track)   /* ca
 
 void TrackFilter::trackfilter_minpoint_list_cb(const route_head* track)
 {
-  if (track->rte_waypt_ct < minimum_points) {
+  if (track->rte_waypt_ct() < minimum_points) {
     track_del_head(const_cast<route_head*>(track));
     return;
   }
@@ -268,7 +268,7 @@ void TrackFilter::trackfilter_pack_init_rte_name(route_head* track, const gpsbab
     // Uggh.  strftime format exposed to user.
 
     gpsbabel::DateTime dt;
-    if (track->rte_waypt_ct == 0) {
+    if (track->rte_waypt_ct() == 0) {
       dt = default_time;
     } else {
       auto* wpt = track->waypoint_list.front();
@@ -388,7 +388,7 @@ void TrackFilter::trackfilter_merge()
       }
     }
 
-    if (master->rte_waypt_ct == 0) {
+    if (master->rte_waypt_ct() == 0) {
       track_del_head(master);
       track_list.clear();
     }
@@ -412,7 +412,7 @@ void TrackFilter::trackfilter_split()
     fatal(MYNAME "-split: Cannot split more than one track, please pack (or merge) before!\n");
   } else if (!track_list.isEmpty()) {
     route_head* master = track_list.first();
-    int count = master->rte_waypt_ct;
+    int count = master->rte_waypt_ct();
 
     int i, j;
     double interval = -1; /* seconds */
@@ -724,7 +724,7 @@ void TrackFilter::trackfilter_range()
       }
     }
 
-    if (track->rte_waypt_ct == 0) {
+    if (track->rte_waypt_ct() == 0) {
       track_del_head(track);
       it = track_list.erase(it);
     } else {
index df7d2b8eeb805969f252072001bd0e07325d1651..50d4b0ef3fcddd612579ee123cf8a1a486b51f34 100644 (file)
@@ -37,10 +37,10 @@ void ValidateFilter::validate_head_trl(const route_head* header)
 {
   int segment_waypt_ct = point_ct - segment_ct_start;
   if (debug) {
-    fprintf(stderr, "%s %d ct: %d, waypt_count: %d\n", segment_type, header->rte_num,  segment_waypt_ct, header->rte_waypt_ct);
+    fprintf(stderr, "%s %d ct: %d, waypt_count: %d\n", segment_type, header->rte_num,  segment_waypt_ct, header->rte_waypt_ct());
   }
-  if (!debug && (segment_waypt_ct != header->rte_waypt_ct)) {
-    fatal(MYNAME ":%s %d count mismatch, expected %d, actual %d\n", segment_type, header->rte_num, header->rte_waypt_ct, segment_waypt_ct);
+  if (!debug && (segment_waypt_ct != header->rte_waypt_ct())) {
+    fatal(MYNAME ":%s %d count mismatch, expected %d, actual %d\n", segment_type, header->rte_num, header->rte_waypt_ct(), segment_waypt_ct);
   }
 }
 
diff --git a/xol.cc b/xol.cc
index 474a8f87f5b21b71c384c3ec97adb44b1630419e..b5cd7ea4076a5feda138db9b34e81e21596b0e2f 100644 (file)
--- a/xol.cc
+++ b/xol.cc
@@ -110,7 +110,7 @@ static void xol_shape_end(xg_string, const QXmlStreamAttributes*) {
     }
     wpt_ = nullptr;
   } else if (trk_) {
-    if (trk_->rte_waypt_ct == 0) {
+    if (trk_->rte_waypt_ct() == 0) {
       track_del_head(trk_);
     }
     trk_ = nullptr;